#!/usr/bin/python
# -*- coding: utf-8 -*-
"""
Mikan mako ビュー 機能

Mikan Python Web Framework
"""

__author__ = "K.Sonohara"
__status__ = "develop"
__version__ = "0.0.0_7"
__date__    = "2013/02/24"
__license__ = 'LGPL'

# ------------------------------------------------------------
## インポート
# ------------------------------------------------------------
# Python

# mako
from mako.template import Template

# ESiPC
from esipc import ESiPCProperty

# Mikan
from mikan.view import MikanHTMLView

# ------------------------------------------------------------
## 変数
# ------------------------------------------------------------

# ------------------------------------------------------------
## 関数
# ------------------------------------------------------------

# ------------------------------------------------------------
## クラス
# ------------------------------------------------------------

class MikanMakoView(MikanHTMLView):
	def __init__(self, r, filename=None, values={}):
		self.FFilename = filename
		self.FValues = values

		super(MikanMakoView, self).__init__(r)

	def get_values(self):
		return self.FValues

	def get_filename(self):
		return self.FFilename

	def set_values(self, value):
		self.FValues = value

	def set_filename(self, value):
		self.FFilename = value

	def get_content(self):
		self.build_template()
		return self.FContent

	def build_template(self):
		t = Template(filename=self.filename,
		    input_encoding="utf-8",
		    output_encoding=self.encode,
		    encoding_errors="replace")

		self.FContent = t.render(**self.values)

	# ----------------------------------------------------
	## Property
	filename = ESiPCProperty(get_filename, set_filename, None)
	values = ESiPCProperty(get_values, set_values, None)

# ------------------------------------------------------------
## メイン関数
# ------------------------------------------------------------
## メイン処理
if __name__ == '__main__':
	pass

# ------------------------------------------------------------
